<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>添加楼座单元</title>
  </head>
  <body>
    <script type="text/javascript">
      Ext.onReady(function(){
        var buildingUnitNumber = new Ext.form.TextField({
          fieldLabel: '楼座单元编号',
          allowBlank: false,
          name: 'number',
          anchor: '90%'
        });

        var buildingUnitName = new Ext.form.TextField({
          fieldLabel: '楼座单元名称',
          allowBlank: false,
          name: 'name',
          anchor: '90%'
        });

        //付款方式
        var buildingType = new Ext.form.RadioGroup({
          //width : 220,
          fieldLabel: '建筑类型',
          //hideLabel:true,
          //style:'margin-left:100px;margin-top:20px',
          columns : 2,
          anchor: '100%',
          vertical :false,
          items:[
            {boxLabel:'多层',inputValue:'多层',name:'sub_type',checked:true},
            {boxLabel:'高层',inputValue:'高层',name:'sub_type'}
          ]
        });
        
        //提交按钮
        var addBuildingUnitButton = new Ext.Button({
          text: '提交',
          iconCls: 'icon-save',
          handler: function(){
            addBuildingUnitButton.setDisabled(true);
            if (newBuildingUnitFormPanel.form.isValid()) {
              newBuildingUnitFormPanel.form.submit({
                success: function(result, resp){
                  if (resp.result.info.indexOf("成功") >= 0) {
                    newBuildingUnitWin.destroy();
                    buildingUnitDS.reload();
                  } else {
                    Ext.MessageBox.alert('消息', resp.result.info);
                    addBuildingUnitButton.enable();
                  }
                },
                failure: function(result, request){
                  addBuildingUnitButton.enable();
                  Ext.MessageBox.alert('消息', '服务器的通信失败!');
                }
              });
            }
            else {
              addBuildingUnitButton.enable();
              //Ext.MessageBox.alert('输入验证有错', '请输入必输选项');
            }
          }
        })
        
        var newBuildingUnitFormPanel = new Ext.form.FormPanel({
          labelWidth: 80,
          width: '260',
          labelAlign: 'right',
          frame : true,
          url: '/building/createBuildingUnit',
          items: [buildingUnitNumber,buildingUnitName,buildingType],
          buttons: [addBuildingUnitButton,{
              text: '关闭',
              iconCls: 'exit',
              handler: function(){
                newBuildingUnitWin.destroy();
              }
            }]
        });
        newBuildingUnitFormPanel.render('new_buildingUnit_form');
      })
    </script>
    <div id="new_buildingUnit_form"></div>
  </body>
</html>
